package com.crl.module.avatar.model
{
	import flash.events.Event;
	import flash.events.EventDispatcher;
	
	public class InfoContainer extends EventDispatcher
	{
		private var info:Object;
		
		public function InfoContainer(obj:Object)
		{
			info={};
			fillData(obj);
		}
		
		/**
		 * 填充数据;
		 * @param obj
		 * @param fireEvent
		 * 
		 */		
		public function fillData(obj:Object,fireEvent:Boolean=true):void{
			for(var key:String in obj){
				info[key]=obj[key];
			}
			
			if(fireEvent){
				this.dispatchEvent(new Event(Event.CHANGE));
			}
		}
		
		public function getString(pro:String,defaultValue=""):String{
			return getObject(pro,defaultValue).toString();
		}
		
		
		public function getInt(pro:String,defaultValue:int=-1):void{
			return int(getObject(pro,defaultValue))
		}
		
		public function getObject(pro:String,def:*=null):*{
			var o:*=info[pro];
			if (o==null || o == undefined){
				return def;
			}
			return o;
		}
		
		
	}
}